# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pymediainfo
pkgname=python-pymediainfo
pkgver=6.1.0
pkgrel=1
pkgdesc="A Python wrapper around the MediaInfo library"
arch=(any)
url="https://github.com/sbraz/pymediainfo/"
license=(MIT)
depends=(
  libmediainfo
  python
  python-importlib-metadata
)
makedepends=(
  mediainfo
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-runner
)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('53e035ac40a17e95353d8bbe7045fd68b6c56cfc2d12d2aa503e1495dc533bced2cf50066453de4424ca9fd7b125b5b8c1dd6f59e9862cf9b4bdb259b29b6ee0')
b2sums=('46dd64c7b841e2771e6e36caac91c59fbc1631c40970bd013cd1b66b4c969dcb1fb928d221d5fcf0962426ef98327b4a12439669ae7001af6dbf8b40fd3644a0')

build() {
  cd $_name-$pkgver
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {AUTHORS,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
}
